<!DOCTYPE html>
<html class="no-js" lang="zh_CN">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <title>${system_admin_title}</title>
    #required_css
</head>

<body>#loading

<div class="app $!layout">
    <!-- 头部菜单 -->#header
    <section class="layout">
        <!-- 菜单 -->
        #sidebar
        <!-- 内容主体 -->
        <section class="container">
            <section class="main-content">
                <div class="content-wrap">
                    <div class="wrapper">
                        <div class="row clearfix">
                            <div class="col-lg-12 col-md-12">
                                <table id="dgFlowApply"></table>
                                <div id="dgFlowApplyPager"></div>
                            </div>
                        </div>
                    </div>
                    <a class="exit-offscreen"></a>
                </div>
            </section>
        </section>
    </section>
</div>
#required_js
<!-- 页面组件 -->

<!-- 本页面脚本 -->
<script src="$!basePath/framework/js/view/toast.js"></script>
<script type="text/javascript">
    ns.requireJS([
        "/framework/js/form/checkbox.js",
        "/framework/js/view/datagrid.js",
        "/framework/js/form/search.form.js"]);
    var dgFlowApply;
    ns.ready(function () {
        dgFlowApply = $("#dgFlowApply").jqGrid({
            url: '$!basePath/bi/flow/apply/data',
            colModel: [
                {label: 'ID', name: 'id', key: true, hidden: true, align: "left"},
                {label: '流程名称', name: 'name', width: 100},
                {label: '流程Key', name: 'key', width: 100},
                {label: '描述', name: 'descript', width: 300},
                {
                    label: '操作', width: 50, formatter: function (val, node, data) {
                    return ns.view.datagrid.renderOp([{
                        title: "启动流程", onclick: function () {
                            doStart(data.id);
                        }
                    }]);
                }
                }
            ],
            height: $(".main-content .wrapper").height() - ns.view.datagrid.offsetHeight,
            pager: "#dgFlowApplyPager",
            rownumbers: true,
//            searchForm : "#searchForm",
        });
    });

    function doStart(id) {
        jQuery.post("$!basePath/bi/flow/apply/start/" + id, {}, function (data) {
            if (data.success == true) {
                if (data.type == "form") {
                    window.open("$!basePath/bi/form/design/preview/" + data.formKey + "?tid=" + id + "&start=true");
                } else {
                    Toast.success("流程启动成功！");
                }
            } else {
                Toast.error(data.message);
            }
        });
    }
</script>
#loading_close
</body>

</html>